<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .top{
            margin: 0 auto;
            width: 400px;
            text-align: center;
        }
        button{
            margin-bottom: 10px;
        }

        #box {
            width: 100px;
            height: 100px;
            background-color: rgb(0, 0, 0);
            margin: 0 auto;
            display: block;
        }
        .width{
            width: 200px;
            height: 100px;
            background-color: rgb(0, 0, 0);
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <p class="top">
        <button onclick="btn1()">变宽</button>
        <button onclick="btn2()">变高</button>
        <button onclick="btn3()">变色</button>
        <button onclick="btn4()">隐藏</button>
        <button onclick="btn5()">重置</button>
        <div id="box"></div>
    </p>

    <script>
        var div = document.getElementById('box')
        function btn1(){
            div.style.width = '200px'
        }

        function btn2(){
            div.style.height = '200px'
        }

        function btn3(){
            div.style.backgroundColor = 'pink'
        }
        

        function btn4(){
            if(div.style.display == ''){
                div.style.display = 'none'
            }else if(div.style.display == 'block'){
                div.style.display = 'none'
            }else {
                div.style.display = 'block'
            }
            
        }

        function btn5(){
            div.style.width = '100px'
            div.style.height = '100px'
            div.style.backgroundColor = 'rgb(0,0,0)'
            div.style.display = 'block'
        }

    </script>
</body>

</html>